package com.tedu.web;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class Register extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        //但凡给客户端东西都是response给
        //response没有 办法直接给，通过PrintWriter输出
        PrintWriter out=resp.getWriter();
        UserDao dao = new UserDao();

        if(dao.register(username, password)){
            out.println("注册成功！");
        }else{
            out.println("注册失败！");
        }
    }
}
